import request from '@/config/axios'

// 物流公司联系人 VO
export interface LogistContactVO {
  id: number
  name: string
  sex?: string
  position?: string
  email?: string
  landline?: string
  phone: string
  facebook?: string
  ins?: string
  tiktok?: string
  youtube?: string
  linkedin?: string
  remark?: string
}

// 物流公司信息 VO
export interface LogistCompanyVO {
  id: number // id
  code?: string // 物流公司编号
  name: string // 物流公司名称
  logisticsClass: string // 物流公司分类
  scope?: string // 经营范围
  scale?: string // 公司规模
  phone?: string // 公司电话
  email?: string
  fax?: string
  website?: string
  remark?: string // 备注
  contacts: LogistContactVO[] // 联系人列表
}


// 物流公司信息 API
export const LogistCompanyApi = {
  // 查询物流公司信息分页
  getLogistCompanyPage: async (params: any) => {
    return await request.get({ url: `/business/logist-company/page`, params })
  },

  // 新增物流公司信息
  createLogistCompany: async (data: LogistCompanyVO) => {
    return await request.post({ url: `/business/logist-company/create`, data })
  },

  // 编辑物流公司信息
  updateLogistCompany: async (data: LogistCompanyVO) => {
    return await request.put({ url: `/business/logist-company/update`, data })
  },

  // 删除物流公司信息
  deleteLogistCompany: async (ids: number[]) => {
    return await request.delete({ 
    url: `/business/logist-company/delete?ids=${ids.join(',')}`, })
  },

  // 获取行业分类信息
  getLogisticsClass: async () => {
    return await request.get({ url: `/business/logist-company/getLogisticsClass`})
  },

  // 获取物流公司详情
  getLogistCompany: async (id: number) => {
    return await request.post({ url: `/business/logist-company/get/${id}`})
  },
}
// 获取联系人列表（根据物流公司ID）
export const getLogistContacts = (logistId: string | number) => {
  return request.get({
    url: '/business/logist-company/detail',
    params: { logistId }
  })
}
